package tom.spring.cloud.amqp.rabbitmq.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import tom.spring.cloud.amqp.rabbitmq.service.MsgProducer;

/**
 * @author ZHUFEIFEI
 */
@RestController
public class MsgController {

    @Autowired
    private MsgProducer producer;

    /**
     * direct 一对一消息
     * @param msg
     * @return
     */
    @GetMapping("direct")
    public String sendDirect(String msg) {
        this.producer.sendDirect(msg);
        return msg;
    }

    /**
     * topic 订阅
     * @param msg
     * @return
     */
    @GetMapping("topic")
    public String sendTopic(String msg) {
        this.producer.sendTopic(msg);
        return msg;
    }

    /**
     * fanout广播
     * @param msg
     * @return
     */
    @GetMapping("fanout")
    public String sendFanout(String msg) {
        this.producer.sendFanout(msg);
        return msg;
    }
}
